<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>ob_start 回调函数压缩输出缓冲区</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.ob-get-status.html">« ob_get_status</a></li>
      <li style="float: right;"><a href="function.ob-implicit-flush.html">ob_implicit_flush »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.outcontrol.html">Output Control 函数</a></li>
    <li>ob_start 回调函数压缩输出缓冲区</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.ob-gzhandler" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ob_gzhandler</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ob_gzhandler</span> &mdash; <span class="dc-title"> ob_start 回调函数压缩输出缓冲区</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.ob-gzhandler-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ob_gzhandler</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>ob_gzhandler()</strong></span> 目的用作 <span class="function"><a href="function.ob-start.html" class="function">ob_start()</a></span>
   的回调函数，以便将 gz 编码的数据发送到支持网页压缩的 Web 浏览器。在 <span class="function"><strong>ob_gzhandler()</strong></span>
   实际发送压缩数据之前，该函数会确定浏览器接受哪种类型的内容编码（&quot;gzip&quot;、&quot;deflate&quot;
   或都不接受），然后相应的返回输出。支持所有发送正确头消息以表明接受压缩网页的浏览器。如果浏览器不支持压缩页面，则函数返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ob-gzhandler-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">data</code></dt>

     <dd>

      <p class="para">
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">flags</code></dt>

     <dd>

      <p class="para">
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ob-gzhandler-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ob-gzhandler-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-540">
    <p><strong>示例 #1 <span class="function"><strong>ob_gzhandler()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />ob_start</span><span style="color: #007700">(</span><span style="color: #DD0000">"ob_gzhandler"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;<br /></span>&lt;html&gt;<br />&lt;body&gt;<br />&lt;p&gt;This&nbsp;should&nbsp;be&nbsp;a&nbsp;compressed&nbsp;page.&lt;/p&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.ob-gzhandler-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    <span class="function"><strong>ob_gzhandler()</strong></span> 需要 <a href="ref.zlib.html" class="link">zlib</a> 扩展。
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    不能同时使用 <span class="function"><strong>ob_gzhandler()</strong></span> 和 <a href="zlib.configuration.html#ini.zlib.output-compression" class="link">zlib.output_compression</a>。也要注意使用
    <a href="zlib.configuration.html#ini.zlib.output-compression" class="link">zlib.output_compression</a> 要优于
    <span class="function"><strong>ob_gzhandler()</strong></span>。
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ob-gzhandler-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.ob-start.html" class="function" rel="rdfs-seeAlso">ob_start()</a> - 打开输出控制缓冲</span></li>
    <li class="member"><span class="function"><a href="function.ob-end-flush.html" class="function" rel="rdfs-seeAlso">ob_end_flush()</a> - 冲刷出（送出）输出缓冲区内容并关闭缓冲区</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>